// 用户相关的 API
import request from "@/utils/request";
import {getToken} from "@/utils/localData";
// 登录
export const userLoginAPI = (data) => {
	return request({
		method: "post",
		url: "/login",
		data,
	});
};
// 注册
export const userRegisterAPI = (data) => {
	return request({
		method: "post",
		url: "/register",
		data,
	});
};
// 用户详情
export const userDetailAPI = (id) => {
	return request({
		method: "get",
		url: "/user/" + id,
		// 用户详情接口需要验证，把本地存储的 token 值带上
		// headers: {
		// 	// Authorization: localStorage.getItem("hmttToken"),
		// 	Authorization: getToken(),
		// }, //用了拦截器就可以省略
	});
};
//编辑用户信息
export const userCompileAPI = (id, data) => {
	return request({
		method: "post",
		url: "/user_update/" + id,
		// 用户详情接口需要验证，把本地存储的 token 值带上
		data,
		// headers: {
		// 	// Authorization: localStorage.getItem("hmttToken"),
		// 	Authorization: getToken(),
		// },
	});
};
//关注用户
export const userFollowAPI = (id) => {
	return request({
		method: "get",
		url: "/user_follows/" + id,
	});
};
//取消关注用户
export const unuserFollowAPI = (id) => {
	return request({
		method: "get",
		url: "/user_unfollow/" + id,
	});
};
//用户关注列表
export const attentionListAPI = () => {
	return request({
		method: "get",
		url: "/user_follows",
	});
};
// 用户收藏列表
export const collectListAPI = () => {
	return request({
		method: "get",
		url: "/user_star",
	});
};
// 用户评论列表
export const commentsListAPI = () => {
	return request({
		method: "get",
		url: "/user_comments",
	});
};
